<html>
 <head>
  <meta charset="utf-8"/>
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"/>
  <title>
   SparkR(R on Spark)编程指南  | 数螺 | NAUT IDEA
  </title>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" rel="stylesheet"/>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
  <style type="text/css">
   #xmain img {
                  max-width: 100%;
                  display: block;
                  margin-top: 10px;
                  margin-bottom: 10px;
                }

                #xmain p {
                    line-height:150%;
                    font-size: 16px;
                    margin-top: 20px;
                }

                #xmain h2 {
                    font-size: 24px;
                }

                #xmain h3 {
                    font-size: 20px;
                }

                #xmain h4 {
                    font-size: 18px;
                }


                .header {
	           background-color: #0099ff;
	           color: #ffffff;
	           margin-bottom: 20px;
	        }

	        .header p {
                  margin: 0px;
                  padding: 10px 0;
                  display: inline-block;  
                  vertical-align: middle;
                  font-size: 16px;
               }

               .header a {
                 color: white;
               }

              .header img {
                 height: 25px;
              }
  </style>
  <script src="http://cdn.bootcss.com/jquery/3.0.0/jquery.min.js">
  </script>
  <script src="http://nautstatic-10007657.file.myqcloud.com/static/css/readability.min.js" type="text/javascript">
  </script>
  <script type="text/javascript">
   $(document).ready(function() {
                 var loc = document.location;
                 var uri = {
                  spec: "http://dataunion.org/19410.html",
                  host: "http://dataunion.org",
                  prePath: "http://dataunion.org",
                  scheme: "http",
                  pathBase: "http://dataunion.org/"
                 };
    
                 var documentClone = document.cloneNode(true);
                 var article = new Readability(uri, documentClone).parse();
     
                 document.getElementById("xmain").innerHTML = article.content;
                });
  </script>
  <!-- 1466459683: Accept with keywords: (title(0.2):指南,Spark,编程,数盟,社区, topn(0.5):指南,社区,数盟,深度学习,行业资讯,R语言,数据挖掘,数据分析,文件,内置,人工智能,数据源,数据库,职业规划,文档,文章,基础架构,Spark,数据,函数,编程,可视化,spark,合作伙伴,结构化,编程语言,方法,应用程序,行业,分布式).-->
 </head>
 <body onload="">
  <div class="header">
   <div class="container">
    <div class="row">
     <div class="col-xs-6 col-sm-6 text-left">
      <a href="/databee">
       <img src="http://nautidea-10007657.cos.myqcloud.com/logo_white.png"/>
      </a>
      <a href="/databee">
       <p>
        数螺
       </p>
      </a>
     </div>
     <div class="hidden-xs col-sm-6 text-right">
      <p>
       致力于数据科学的推广和知识传播
      </p>
     </div>
    </div>
   </div>
  </div>
  <div class="container text-center">
   <h1>
    SparkR(R on Spark)编程指南
   </h1>
  </div>
  <div class="container" id="xmain">
   ﻿﻿
   <title>
    SparkR(R on Spark)编程指南 | 数盟社区
   </title>
   <!-- All in One SEO Pack 2.2.7.6.2 by Michael Torbert of Semper Fi Web Design[32,69] -->
   <!-- /all in one seo pack -->
   <!--
<div align="center">
<a href="http://strata.oreilly.com.cn/hadoop-big-data-cn?cmp=mp-data-confreg-home-stcn16_dataunion_pc" target="_blank"><img src="http://dataunion.org/wp-content/uploads/2016/05/stratabj.jpg"/ ></a>
</div>
-->
   <header id="header-web">
    <div class="header-main">
     <hgroup class="logo">
      <h1>
       <a href="http://dataunion.org/" rel="home" title="数盟社区">
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/logo.png"/>
       </a>
      </h1>
     </hgroup>
     <!--logo-->
     <nav class="header-nav">
      <ul class="menu" id="menu-%e4%b8%bb%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-71" id="menu-item-71">
        <a href="http://dataunion.org/category/events" title="events">
         活动
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22457" id="menu-item-22457">
          <a href="http://dataunion.org/2016timeline">
           2016档期
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22459" id="menu-item-22459">
          <a href="http://dataunion.org/category/parterc">
           合作会议
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category current-post-ancestor current-menu-parent current-post-parent menu-item-has-children menu-item-20869" id="menu-item-20869">
        <a href="http://dataunion.org/category/tech" title="articles">
         文章
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20867" id="menu-item-20867">
          <a href="http://dataunion.org/category/tech/base" title="base">
           基础架构
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3302" id="menu-item-3302">
          <a href="http://dataunion.org/category/tech/ai" title="ai">
           人工智能
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3303" id="menu-item-3303">
          <a href="http://dataunion.org/category/tech/analysis" title="analysis">
           数据分析
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21920" id="menu-item-21920">
          <a href="http://dataunion.org/category/tech/dm">
           数据挖掘
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3314" id="menu-item-3314">
          <a href="http://dataunion.org/category/tech/viz" title="viz">
           可视化
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3305" id="menu-item-3305">
          <a href="http://dataunion.org/category/tech/devl" title="devl">
           编程语言
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-20876" id="menu-item-20876">
        <a href="http://dataunion.org/category/industry">
         行业
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-16328" id="menu-item-16328">
          <a href="http://dataunion.org/category/industry/case" title="case">
           行业应用
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-2112" id="menu-item-2112">
          <a href="http://dataunion.org/category/industry/demo" title="demo">
           Demo展示
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21562" id="menu-item-21562">
          <a href="http://dataunion.org/category/industry/news">
           行业资讯
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-311" id="menu-item-311">
        <a href="http://dataunion.org/category/sources" title="sources">
         资源
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20870" id="menu-item-20870">
        <a href="http://dataunion.org/category/books" title="book">
         图书
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21363" id="menu-item-21363">
        <a href="http://dataunion.org/category/training">
         课程
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-21853" id="menu-item-21853">
        <a href="http://dataunion.org/category/jobs">
         职位
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22050" id="menu-item-22050">
          <a href="http://dataunion.org/category/career">
           职业规划
          </a>
         </li>
        </ul>
       </li>
      </ul>
     </nav>
     <!--header-nav-->
    </div>
   </header>
   <!--header-web-->
   <div id="main">
    <div id="soutab">
     <form action="http://dataunion.org/" class="search" method="get">
     </form>
    </div>
    <div id="container">
     <nav id="mbx">
      当前位置：
      <a href="http://dataunion.org">
       首页
      </a>
      &gt;
      <a href="http://dataunion.org/category/tech">
       文章
      </a>
      &gt;  正文
     </nav>
     <!--mbx-->
     <article class="content">
      <header align="centre" class="contenttitle">
       <div class="mscc">
        <h1 class="mscctitle">
         <a href="http://dataunion.org/19410.html">
          SparkR(R on Spark)编程指南
         </a>
        </h1>
        <address class="msccaddress ">
         <em>
          2,261 次阅读 -
         </em>
         <a href="http://dataunion.org/category/tech" rel="category tag">
          文章
         </a>
        </address>
       </div>
      </header>
      <div class="content-text">
       <p>
       </p>
       <blockquote>
        <p>
         出处：
         <a href="http://www.iteblog.com/archives/1385">
          过往记忆
         </a>
        </p>
       </blockquote>
       <h2>
        概论
       </h2>
       <p>
        <span class="wp_keywordlink_affiliate">
         <a data-original-title="View all posts in SparkR" href="http://www.iteblog.com/archives/tag/sparkr" target="_blank" title="">
          SparkR
         </a>
        </span>
        是一个R语言包，它提供了轻量级的方式使得可以在R语言中使用Apache
        <span class="wp_keywordlink_affiliate">
         <a data-original-title="View all posts in Spark" href="http://www.iteblog.com/archives/tag/spark" target="_blank" title="">
          Spark
         </a>
        </span>
        。在
        <span class="wp_keywordlink_affiliate">
         <a data-original-title="View all posts in Spark" href="http://www.iteblog.com/archives/tag/spark" target="_blank" title="">
          Spark
         </a>
        </span>
        1.4中，
        <span class="wp_keywordlink_affiliate">
         <a data-original-title="View all posts in SparkR" href="http://www.iteblog.com/archives/tag/sparkr" target="_blank" title="">
          SparkR
         </a>
        </span>
        实现了分布式的data frame，支持类似查询、过滤以及聚合的操作（类似于R中的data frames：dplyr)，但是这个可以操作大规模的数据集。
       </p>
       <h2>
        <span class="wp_keywordlink_affiliate">
         <a data-original-title="View all posts in SparkR" href="http://www.iteblog.com/archives/tag/sparkr" target="_blank" title="">
          SparkR
         </a>
        </span>
        DataFrames
       </h2>
       <p>
        DataFrame是数据组织成一个带有列名称的分布式数据集。在概念上和关系型数据库中的表类似，或者和R语言中的data frame类似，但是这个提供了很多的优化措施。构造DataFrame的方式有很多：可以通过结构化文件中构造；可以通过Hive中的表构造；可以通过外部数据库构造或者是通过现有R的data frame构造等等。
       </p>
       <div class="wp-caption aligncenter">
        <a class="qa-blog-zoom" href="http://dataunion.org/wp-content/uploads/2015/06/spar.png">
         <img src="http://dataunion.org/wp-content/uploads/2015/06/spar.png"/>
        </a>
       </div>
       <h3>
        从
        <span class="wp_keywordlink_affiliate">
         <a data-original-title="View all posts in Spark" href="http://www.iteblog.com/archives/tag/spark" target="_blank" title="">
          Spark
         </a>
        </span>
        Context和SQLContext开始
       </h3>
       <p>
        SparkContext是SparkR的切入点，它使得你的R程序和Spark集群互通。你可以通过sparkR.init来构建SparkContext，然后可以传入类似于应用程序名称的选项给它。如果想使用DataFrames，我们得创建SQLContext，这个可以通过SparkContext来构造。如果你使用SparkR shell， SQLContext 和SparkContext会自动地构建好。
       </p>
       <div class="syntaxhighlighter " id="highlighter_966978">
        <div class="lines">
         <div class="line alt1">
          <blockquote>
           <p>
           </p>
           <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
           <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5768661ee5338055041473" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
            <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
             <span class="crayon-title">
             </span>
             <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
              <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-wrap-button" title="切换自动换行">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-expand-button" title="点击展开代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-copy-button" title="复制代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
               <div class="crayon-button-icon">
               </div>
              </div>
             </div>
            </div>
            <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
            </div>
            <div class="crayon-plain-wrap">
             <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
              sc &amp;lt;- sparkR.init()
sqlContext &amp;lt;- sparkRSQL.init(sc)
             </textarea>
            </div>
            <div class="crayon-main" style="">
             <table class="crayon-table">
              <tbody>
               <tr class="crayon-row">
                <td class="crayon-nums " data-settings="show">
                 <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                  <div class="crayon-num" data-line="crayon-5768661ee5338055041473-1">
                   1
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee5338055041473-2">
                   2
                  </div>
                 </div>
                </td>
                <td class="crayon-code">
                 <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                  <div class="crayon-line" id="crayon-5768661ee5338055041473-1">
                   <span class="crayon-v">
                    sc
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-o">
                    -
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    sparkR
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    init
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee5338055041473-2">
                   <span class="crayon-v">
                    sqlContext
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-o">
                    -
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    sparkRSQL
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    init
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    sc
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                 </div>
                </td>
               </tr>
              </tbody>
             </table>
            </div>
           </div>
           <!-- [Format Time: 0.0049 seconds] -->
           <p>
           </p>
          </blockquote>
         </div>
        </div>
       </div>
       <h3>
        创建DataFrames
       </h3>
       <p>
        如果有SQLContext实例，那么应用程序就可以通过本地的R data frame（或者是Hive表；或者是其他数据源）来创建DataFrames。下面将详细地介绍。
       </p>
       <p>
        <strong>
         通过本地data frame构造
        </strong>
       </p>
       <p>
        最简单地创建DataFrames是将R的data frame转换成SparkR DataFrames，我们可以通过createDataFrame来创建，并传入本地R的data frame以此来创建SparkR DataFrames，下面例子就是这种方法：
       </p>
       <div class="syntaxhighlighter " id="highlighter_370990">
        <div class="lines">
         <div class="line alt1">
          <blockquote>
           <p>
           </p>
           <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
           <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5768661ee5345914847277" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
            <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
             <span class="crayon-title">
             </span>
             <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
              <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-wrap-button" title="切换自动换行">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-expand-button" title="点击展开代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-copy-button" title="复制代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
               <div class="crayon-button-icon">
               </div>
              </div>
             </div>
            </div>
            <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
            </div>
            <div class="crayon-plain-wrap">
             <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
              df &amp;lt;- createDataFrame(sqlContext, faithful) 

# Displays the content of the DataFrame to stdout
head(df)
##  eruptions waiting
##1     3.600      79
##2     1.800      54
##3     3.333      74
             </textarea>
            </div>
            <div class="crayon-main" style="">
             <table class="crayon-table">
              <tbody>
               <tr class="crayon-row">
                <td class="crayon-nums " data-settings="show">
                 <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                  <div class="crayon-num" data-line="crayon-5768661ee5345914847277-1">
                   1
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee5345914847277-2">
                   2
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee5345914847277-3">
                   3
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee5345914847277-4">
                   4
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee5345914847277-5">
                   5
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee5345914847277-6">
                   6
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee5345914847277-7">
                   7
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee5345914847277-8">
                   8
                  </div>
                 </div>
                </td>
                <td class="crayon-code">
                 <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                  <div class="crayon-line" id="crayon-5768661ee5345914847277-1">
                   <span class="crayon-v">
                    df
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-o">
                    -
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-e">
                    createDataFrame
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    sqlContext
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    faithful
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-h">
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee5345914847277-2">
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee5345914847277-3">
                   <span class="crayon-p">
                    # Displays the content of the DataFrame to stdout
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee5345914847277-4">
                   <span class="crayon-e">
                    head
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    df
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee5345914847277-5">
                   <span class="crayon-p">
                    ##  eruptions waiting
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee5345914847277-6">
                   <span class="crayon-p">
                    ##1     3.600      79
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee5345914847277-7">
                   <span class="crayon-p">
                    ##2     1.800      54
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee5345914847277-8">
                   <span class="crayon-p">
                    ##3     3.333      74
                   </span>
                  </div>
                 </div>
                </td>
               </tr>
              </tbody>
             </table>
            </div>
           </div>
           <!-- [Format Time: 0.0093 seconds] -->
           <p>
           </p>
          </blockquote>
         </div>
        </div>
       </div>
       <p>
        <strong>
         通过Data Sources构造
        </strong>
       </p>
       <p>
        通过DataFrame接口，SparkR支持操作多种数据源，本节将介绍如何通过Data Sources提供的方法来加载和保存数据。你可以阅读Spark SQL编程指南来了解更多的options选项.
       </p>
       <p>
        Data Sources中创建DataFrames的一般方法是使用read.df，这个方法需要传入SQLContext，需要加载的文件路径以及数据源的类型。SparkR内置支持读取JSON和Parquet文件，而且通过Spark Packages你可以读取很多类型的数据，比如CSV和Avro文件。
       </p>
       <p>
        下面是介绍如何JSON文件，注意，这里使用的文件不是典型的JSON文件。每行文件必须包含一个分隔符、自包含有效的JSON对象：
       </p>
       <div class="syntaxhighlighter " id="highlighter_227494">
        <div class="lines">
         <div class="line alt1">
          <blockquote>
           <p>
           </p>
           <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
           <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5768661ee534d845220444" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
            <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
             <span class="crayon-title">
             </span>
             <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
              <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-wrap-button" title="切换自动换行">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-expand-button" title="点击展开代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-copy-button" title="复制代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
               <div class="crayon-button-icon">
               </div>
              </div>
             </div>
            </div>
            <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
            </div>
            <div class="crayon-plain-wrap">
             <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
              people &amp;lt;- read.df(sqlContext, "./examples/src/main/resources/people.json", "json")
head(people)
##  age    name
##1  NA Michael
##2  30    Andy
##3  19  Justin

# SparkR automatically infers the schema from the JSON file
printSchema(people)
# root
#  |-- age: integer (nullable = true)
#  |-- name: string (nullable = true)
             </textarea>
            </div>
            <div class="crayon-main" style="">
             <table class="crayon-table">
              <tbody>
               <tr class="crayon-row">
                <td class="crayon-nums " data-settings="show">
                 <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                  <div class="crayon-num" data-line="crayon-5768661ee534d845220444-1">
                   1
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee534d845220444-2">
                   2
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee534d845220444-3">
                   3
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee534d845220444-4">
                   4
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee534d845220444-5">
                   5
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee534d845220444-6">
                   6
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee534d845220444-7">
                   7
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee534d845220444-8">
                   8
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee534d845220444-9">
                   9
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee534d845220444-10">
                   10
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee534d845220444-11">
                   11
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee534d845220444-12">
                   12
                  </div>
                 </div>
                </td>
                <td class="crayon-code">
                 <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                  <div class="crayon-line" id="crayon-5768661ee534d845220444-1">
                   <span class="crayon-v">
                    people
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-o">
                    -
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    read
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    df
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    sqlContext
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-s">
                    "./examples/src/main/resources/people.json"
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-s">
                    "json"
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee534d845220444-2">
                   <span class="crayon-e">
                    head
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    people
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee534d845220444-3">
                   <span class="crayon-p">
                    ##  age    name
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee534d845220444-4">
                   <span class="crayon-p">
                    ##1  NA Michael
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee534d845220444-5">
                   <span class="crayon-p">
                    ##2  30    Andy
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee534d845220444-6">
                   <span class="crayon-p">
                    ##3  19  Justin
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee534d845220444-7">
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee534d845220444-8">
                   <span class="crayon-p">
                    # SparkR automatically infers the schema from the JSON file
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee534d845220444-9">
                   <span class="crayon-e">
                    printSchema
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    people
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee534d845220444-10">
                   <span class="crayon-p">
                    # root
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee534d845220444-11">
                   <span class="crayon-p">
                    #  |-- age: integer (nullable = true)
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee534d845220444-12">
                   <span class="crayon-p">
                    #  |-- name: string (nullable = true)
                   </span>
                  </div>
                 </div>
                </td>
               </tr>
              </tbody>
             </table>
            </div>
           </div>
           <!-- [Format Time: 0.0098 seconds] -->
           <p>
           </p>
          </blockquote>
         </div>
        </div>
       </div>
       <p>
        Data sources API还可以将DataFrames保存成多种的文件格式，比如我们可以通过write.df将上面的DataFrame保存成Parquet文件：
       </p>
       <div class="syntaxhighlighter " id="highlighter_460938">
        <div class="lines">
         <div class="line alt1">
          <blockquote>
           <p>
           </p>
           <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
           <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5768661ee5354831218105" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
            <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
             <span class="crayon-title">
             </span>
             <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
              <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-wrap-button" title="切换自动换行">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-expand-button" title="点击展开代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-copy-button" title="复制代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
               <div class="crayon-button-icon">
               </div>
              </div>
             </div>
            </div>
            <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
            </div>
            <div class="crayon-plain-wrap">
             <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
              write.df(people, path="people.parquet", source="parquet", mode="overwrite")
             </textarea>
            </div>
            <div class="crayon-main" style="">
             <table class="crayon-table">
              <tbody>
               <tr class="crayon-row">
                <td class="crayon-nums " data-settings="show">
                 <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                  <div class="crayon-num" data-line="crayon-5768661ee5354831218105-1">
                   1
                  </div>
                 </div>
                </td>
                <td class="crayon-code">
                 <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                  <div class="crayon-line" id="crayon-5768661ee5354831218105-1">
                   <span class="crayon-v">
                    write
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    df
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    people
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    path
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-s">
                    "people.parquet"
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    source
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-s">
                    "parquet"
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    mode
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-s">
                    "overwrite"
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                 </div>
                </td>
               </tr>
              </tbody>
             </table>
            </div>
           </div>
           <!-- [Format Time: 0.0012 seconds] -->
           <p>
           </p>
          </blockquote>
         </div>
        </div>
       </div>
       <p>
        <strong>
         通过Hive tables构造
        </strong>
       </p>
       <p>
        我们也可以通过Hive表来创建SparkR DataFrames，为了达到这个目的，我们需要创建HiveContext，因为我们可以通过它来访问Hive MetaStore中的表。注意，Spark内置就对Hive提供了支持，SQLContext和HiveContext 的区别可以参见SQL编程指南。
       </p>
       <div class="syntaxhighlighter " id="highlighter_687920">
        <div class="lines">
         <div class="line alt1">
          <blockquote>
           <p>
           </p>
           <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
           <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5768661ee535a233709078" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
            <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
             <span class="crayon-title">
             </span>
             <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
              <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-wrap-button" title="切换自动换行">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-expand-button" title="点击展开代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-copy-button" title="复制代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
               <div class="crayon-button-icon">
               </div>
              </div>
             </div>
            </div>
            <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
            </div>
            <div class="crayon-plain-wrap">
             <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
              # sc is an existing SparkContext.
hiveContext &amp;lt;- sparkRHive.init(sc)

sql(hiveContext, "CREATE TABLE IF NOT EXISTS src (key INT, value STRING)")
sql(hiveContext, "LOAD DATA LOCAL INPATH 'examples/src/main/resources/kv1.txt' INTO TABLE src")

# Queries can be expressed in HiveQL.
results &amp;lt;- hiveContext.sql("FROM src SELECT key, value")

# results is now a DataFrame
head(results)
##  key   value
## 1 238 val_238
## 2  86  val_86
## 3 311 val_311
             </textarea>
            </div>
            <div class="crayon-main" style="">
             <table class="crayon-table">
              <tbody>
               <tr class="crayon-row">
                <td class="crayon-nums " data-settings="show">
                 <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                  <div class="crayon-num" data-line="crayon-5768661ee535a233709078-1">
                   1
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee535a233709078-2">
                   2
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee535a233709078-3">
                   3
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee535a233709078-4">
                   4
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee535a233709078-5">
                   5
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee535a233709078-6">
                   6
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee535a233709078-7">
                   7
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee535a233709078-8">
                   8
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee535a233709078-9">
                   9
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee535a233709078-10">
                   10
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee535a233709078-11">
                   11
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee535a233709078-12">
                   12
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee535a233709078-13">
                   13
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee535a233709078-14">
                   14
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee535a233709078-15">
                   15
                  </div>
                 </div>
                </td>
                <td class="crayon-code">
                 <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                  <div class="crayon-line" id="crayon-5768661ee535a233709078-1">
                   <span class="crayon-p">
                    # sc is an existing SparkContext.
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee535a233709078-2">
                   <span class="crayon-v">
                    hiveContext
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-o">
                    -
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    sparkRHive
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    init
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    sc
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee535a233709078-3">
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee535a233709078-4">
                   <span class="crayon-e">
                    sql
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    hiveContext
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-s">
                    "CREATE TABLE IF NOT EXISTS src (key INT, value STRING)"
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee535a233709078-5">
                   <span class="crayon-e">
                    sql
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    hiveContext
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-s">
                    "LOAD DATA LOCAL INPATH 'examples/src/main/resources/kv1.txt' INTO TABLE src"
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee535a233709078-6">
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee535a233709078-7">
                   <span class="crayon-p">
                    # Queries can be expressed in HiveQL.
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee535a233709078-8">
                   <span class="crayon-v">
                    results
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-o">
                    -
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    hiveContext
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    sql
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-s">
                    "FROM src SELECT key, value"
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee535a233709078-9">
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee535a233709078-10">
                   <span class="crayon-p">
                    # results is now a DataFrame
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee535a233709078-11">
                   <span class="crayon-e">
                    head
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    results
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee535a233709078-12">
                   <span class="crayon-p">
                    ##  key   value
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee535a233709078-13">
                   <span class="crayon-p">
                    ## 1 238 val_238
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee535a233709078-14">
                   <span class="crayon-p">
                    ## 2  86  val_86
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee535a233709078-15">
                   <span class="crayon-p">
                    ## 3 311 val_311
                   </span>
                  </div>
                 </div>
                </td>
               </tr>
              </tbody>
             </table>
            </div>
           </div>
           <!-- [Format Time: 0.0104 seconds] -->
           <p>
           </p>
          </blockquote>
         </div>
        </div>
       </div>
       <h2>
        DataFrame的相关操作
       </h2>
       <p>
        SparkR DataFrames中提供了大量操作结构化数据的函数，这里仅仅列出其中一小部分，详细的API可以参见SparkR编程的API文档。
       </p>
       <h3>
        选择行和列
       </h3>
       <div class="syntaxhighlighter " id="highlighter_286650">
        <div class="lines">
         <div class="line alt1">
          <blockquote>
           <p>
           </p>
           <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
           <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5768661ee5365868149427" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
            <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
             <span class="crayon-title">
             </span>
             <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
              <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-wrap-button" title="切换自动换行">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-expand-button" title="点击展开代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-copy-button" title="复制代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
               <div class="crayon-button-icon">
               </div>
              </div>
             </div>
            </div>
            <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
            </div>
            <div class="crayon-plain-wrap">
             <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
              # Create the DataFrame
df &amp;lt;- createDataFrame(sqlContext, faithful) 

# Get basic information about the DataFrame
df
## DataFrame[eruptions:double, waiting:double]

# Select only the "eruptions" column
head(select(df, df$eruptions))
##  eruptions
##1     3.600
##2     1.800
##3     3.333

# You can also pass in column name as strings 
head(select(df, "eruptions"))

# Filter the DataFrame to only retain rows with wait times shorter than 50 mins
head(filter(df, df$waiting &amp;lt; 50))
##  eruptions waiting
##1     1.750      47
##2     1.750      47
##3     1.867      48
             </textarea>
            </div>
            <div class="crayon-main" style="">
             <table class="crayon-table">
              <tbody>
               <tr class="crayon-row">
                <td class="crayon-nums " data-settings="show">
                 <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                  <div class="crayon-num" data-line="crayon-5768661ee5365868149427-1">
                   1
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee5365868149427-2">
                   2
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee5365868149427-3">
                   3
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee5365868149427-4">
                   4
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee5365868149427-5">
                   5
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee5365868149427-6">
                   6
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee5365868149427-7">
                   7
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee5365868149427-8">
                   8
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee5365868149427-9">
                   9
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee5365868149427-10">
                   10
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee5365868149427-11">
                   11
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee5365868149427-12">
                   12
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee5365868149427-13">
                   13
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee5365868149427-14">
                   14
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee5365868149427-15">
                   15
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee5365868149427-16">
                   16
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee5365868149427-17">
                   17
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee5365868149427-18">
                   18
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee5365868149427-19">
                   19
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee5365868149427-20">
                   20
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee5365868149427-21">
                   21
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee5365868149427-22">
                   22
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee5365868149427-23">
                   23
                  </div>
                 </div>
                </td>
                <td class="crayon-code">
                 <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                  <div class="crayon-line" id="crayon-5768661ee5365868149427-1">
                   <span class="crayon-p">
                    # Create the DataFrame
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee5365868149427-2">
                   <span class="crayon-v">
                    df
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-o">
                    -
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-e">
                    createDataFrame
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    sqlContext
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    faithful
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-h">
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee5365868149427-3">
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee5365868149427-4">
                   <span class="crayon-p">
                    # Get basic information about the DataFrame
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee5365868149427-5">
                   <span class="crayon-v">
                    df
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee5365868149427-6">
                   <span class="crayon-p">
                    ## DataFrame[eruptions:double, waiting:double]
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee5365868149427-7">
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee5365868149427-8">
                   <span class="crayon-p">
                    # Select only the "eruptions" column
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee5365868149427-9">
                   <span class="crayon-e">
                    head
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-e">
                    select
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    df
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    df
                   </span>
                   <span class="crayon-sy">
                    $
                   </span>
                   <span class="crayon-v">
                    eruptions
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee5365868149427-10">
                   <span class="crayon-p">
                    ##  eruptions
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee5365868149427-11">
                   <span class="crayon-p">
                    ##1     3.600
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee5365868149427-12">
                   <span class="crayon-p">
                    ##2     1.800
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee5365868149427-13">
                   <span class="crayon-p">
                    ##3     3.333
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee5365868149427-14">
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee5365868149427-15">
                   <span class="crayon-p">
                    # You can also pass in column name as strings
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee5365868149427-16">
                   <span class="crayon-e">
                    head
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-e">
                    select
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    df
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-s">
                    "eruptions"
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee5365868149427-17">
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee5365868149427-18">
                   <span class="crayon-p">
                    # Filter the DataFrame to only retain rows with wait times shorter than 50 mins
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee5365868149427-19">
                   <span class="crayon-e">
                    head
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-e">
                    filter
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    df
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    df
                   </span>
                   <span class="crayon-sy">
                    $
                   </span>
                   <span class="crayon-v">
                    waiting
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    50
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee5365868149427-20">
                   <span class="crayon-p">
                    ##  eruptions waiting
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee5365868149427-21">
                   <span class="crayon-p">
                    ##1     1.750      47
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee5365868149427-22">
                   <span class="crayon-p">
                    ##2     1.750      47
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee5365868149427-23">
                   <span class="crayon-p">
                    ##3     1.867      48
                   </span>
                  </div>
                 </div>
                </td>
               </tr>
              </tbody>
             </table>
            </div>
           </div>
           <!-- [Format Time: 0.0109 seconds] -->
           <p>
           </p>
          </blockquote>
         </div>
        </div>
       </div>
       <h3>
        Grouping和Aggregation
       </h3>
       <div class="syntaxhighlighter " id="highlighter_881125">
        <div class="lines">
         <div class="line alt1">
          <blockquote>
           <p>
           </p>
           <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
           <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5768661ee5371233377018" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
            <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
             <span class="crayon-title">
             </span>
             <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
              <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-wrap-button" title="切换自动换行">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-expand-button" title="点击展开代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-copy-button" title="复制代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
               <div class="crayon-button-icon">
               </div>
              </div>
             </div>
            </div>
            <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
            </div>
            <div class="crayon-plain-wrap">
             <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
              # We use the `n` operator to count the number of times each waiting time appears
head(summarize(groupBy(df, df$waiting), count = n(df$waiting)))
##  waiting count
##1      81    13
##2      60     6
##3      68     1

# We can also sort the output from the aggregation to get the most common waiting times
waiting_counts &amp;lt;- summarize(groupBy(df, df$waiting), count = n(df$waiting))
head(arrange(waiting_counts, desc(waiting_counts$count)))

##   waiting count
##1      78    15
##2      83    14
##3      81    13
             </textarea>
            </div>
            <div class="crayon-main" style="">
             <table class="crayon-table">
              <tbody>
               <tr class="crayon-row">
                <td class="crayon-nums " data-settings="show">
                 <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                  <div class="crayon-num" data-line="crayon-5768661ee5371233377018-1">
                   1
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee5371233377018-2">
                   2
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee5371233377018-3">
                   3
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee5371233377018-4">
                   4
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee5371233377018-5">
                   5
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee5371233377018-6">
                   6
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee5371233377018-7">
                   7
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee5371233377018-8">
                   8
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee5371233377018-9">
                   9
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee5371233377018-10">
                   10
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee5371233377018-11">
                   11
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee5371233377018-12">
                   12
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee5371233377018-13">
                   13
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee5371233377018-14">
                   14
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee5371233377018-15">
                   15
                  </div>
                 </div>
                </td>
                <td class="crayon-code">
                 <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                  <div class="crayon-line" id="crayon-5768661ee5371233377018-1">
                   <span class="crayon-p">
                    # We use the `n` operator to count the number of times each waiting time appears
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee5371233377018-2">
                   <span class="crayon-e">
                    head
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-e">
                    summarize
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-e">
                    groupBy
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    df
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    df
                   </span>
                   <span class="crayon-sy">
                    $
                   </span>
                   <span class="crayon-v">
                    waiting
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    count
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-e">
                    n
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    df
                   </span>
                   <span class="crayon-sy">
                    $
                   </span>
                   <span class="crayon-v">
                    waiting
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee5371233377018-3">
                   <span class="crayon-p">
                    ##  waiting count
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee5371233377018-4">
                   <span class="crayon-p">
                    ##1      81    13
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee5371233377018-5">
                   <span class="crayon-p">
                    ##2      60     6
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee5371233377018-6">
                   <span class="crayon-p">
                    ##3      68     1
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee5371233377018-7">
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee5371233377018-8">
                   <span class="crayon-p">
                    # We can also sort the output from the aggregation to get the most common waiting times
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee5371233377018-9">
                   <span class="crayon-v">
                    waiting_counts
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-o">
                    -
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-e">
                    summarize
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-e">
                    groupBy
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    df
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    df
                   </span>
                   <span class="crayon-sy">
                    $
                   </span>
                   <span class="crayon-v">
                    waiting
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    count
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    =
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-e">
                    n
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    df
                   </span>
                   <span class="crayon-sy">
                    $
                   </span>
                   <span class="crayon-v">
                    waiting
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee5371233377018-10">
                   <span class="crayon-e">
                    head
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-e">
                    arrange
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    waiting_counts
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-e">
                    desc
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    waiting_counts
                   </span>
                   <span class="crayon-sy">
                    $
                   </span>
                   <span class="crayon-v">
                    count
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee5371233377018-11">
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee5371233377018-12">
                   <span class="crayon-p">
                    ##   waiting count
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee5371233377018-13">
                   <span class="crayon-p">
                    ##1      78    15
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee5371233377018-14">
                   <span class="crayon-p">
                    ##2      83    14
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee5371233377018-15">
                   <span class="crayon-p">
                    ##3      81    13
                   </span>
                  </div>
                 </div>
                </td>
               </tr>
              </tbody>
             </table>
            </div>
           </div>
           <!-- [Format Time: 0.0092 seconds] -->
           <p>
           </p>
          </blockquote>
         </div>
        </div>
       </div>
       <h3>
        列上面的操作
       </h3>
       <p>
        SparkR提供了大量的函数用于直接对列进行数据处理的操作。
       </p>
       <div class="syntaxhighlighter " id="highlighter_664806">
        <div class="lines">
         <div class="line alt1">
          <blockquote>
           <p>
           </p>
           <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
           <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5768661ee5379979953243" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
            <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
             <span class="crayon-title">
             </span>
             <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
              <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-wrap-button" title="切换自动换行">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-expand-button" title="点击展开代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-copy-button" title="复制代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
               <div class="crayon-button-icon">
               </div>
              </div>
             </div>
            </div>
            <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
            </div>
            <div class="crayon-plain-wrap">
             <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
              # Convert waiting time from hours to seconds.
# Note that we can assign this to a new column in the same DataFrame
df$waiting_secs &amp;lt;- df$waiting * 60
head(df)
##  eruptions waiting waiting_secs
##1     3.600      79         4740
##2     1.800      54         3240
##3     3.333      74         4440
             </textarea>
            </div>
            <div class="crayon-main" style="">
             <table class="crayon-table">
              <tbody>
               <tr class="crayon-row">
                <td class="crayon-nums " data-settings="show">
                 <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                  <div class="crayon-num" data-line="crayon-5768661ee5379979953243-1">
                   1
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee5379979953243-2">
                   2
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee5379979953243-3">
                   3
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee5379979953243-4">
                   4
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee5379979953243-5">
                   5
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee5379979953243-6">
                   6
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee5379979953243-7">
                   7
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee5379979953243-8">
                   8
                  </div>
                 </div>
                </td>
                <td class="crayon-code">
                 <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                  <div class="crayon-line" id="crayon-5768661ee5379979953243-1">
                   <span class="crayon-p">
                    # Convert waiting time from hours to seconds.
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee5379979953243-2">
                   <span class="crayon-p">
                    # Note that we can assign this to a new column in the same DataFrame
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee5379979953243-3">
                   <span class="crayon-v">
                    df
                   </span>
                   <span class="crayon-sy">
                    $
                   </span>
                   <span class="crayon-v">
                    waiting_secs
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-o">
                    -
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    df
                   </span>
                   <span class="crayon-sy">
                    $
                   </span>
                   <span class="crayon-e ">
                    waiting *
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-cn">
                    60
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee5379979953243-4">
                   <span class="crayon-e">
                    head
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    df
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee5379979953243-5">
                   <span class="crayon-p">
                    ##  eruptions waiting waiting_secs
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee5379979953243-6">
                   <span class="crayon-p">
                    ##1     3.600      79         4740
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee5379979953243-7">
                   <span class="crayon-p">
                    ##2     1.800      54         3240
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee5379979953243-8">
                   <span class="crayon-p">
                    ##3     3.333      74         4440
                   </span>
                  </div>
                 </div>
                </td>
               </tr>
              </tbody>
             </table>
            </div>
           </div>
           <!-- [Format Time: 0.0014 seconds] -->
           <p>
           </p>
          </blockquote>
         </div>
        </div>
       </div>
       <h2>
        在SparkR中运行SQL查询
       </h2>
       <p>
        SparkR DataFrame也可以在Spark SQL中注册成临时表。将DataFrame 注册成表可以允许我们在数据集上运行SQL查询。sql函数可以使得我们直接运行SQL查询，而且返回的结构是DataFrame。
       </p>
       <div class="syntaxhighlighter " id="highlighter_427993">
        <div class="lines">
         <div class="line alt1">
          <blockquote>
           <p>
           </p>
           <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
           <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5768661ee537f811077884" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
            <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
             <span class="crayon-title">
             </span>
             <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
              <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-wrap-button" title="切换自动换行">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-expand-button" title="点击展开代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-copy-button" title="复制代码">
               <div class="crayon-button-icon">
               </div>
              </div>
              <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
               <div class="crayon-button-icon">
               </div>
              </div>
             </div>
            </div>
            <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
            </div>
            <div class="crayon-plain-wrap">
             <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
              # Load a JSON file
people &amp;lt;- read.df(sqlContext, "./examples/src/main/resources/people.json", "json")

# Register this DataFrame as a table.
registerTempTable(people, "people")

# SQL statements can be run by using the sql method
teenagers &amp;lt;- sql(sqlContext, "SELECT name FROM people WHERE age &amp;gt;= 13 AND age &amp;lt;= 19")
head(teenagers)
##    name
##1 Justin
             </textarea>
            </div>
            <div class="crayon-main" style="">
             <table class="crayon-table">
              <tbody>
               <tr class="crayon-row">
                <td class="crayon-nums " data-settings="show">
                 <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                  <div class="crayon-num" data-line="crayon-5768661ee537f811077884-1">
                   1
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee537f811077884-2">
                   2
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee537f811077884-3">
                   3
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee537f811077884-4">
                   4
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee537f811077884-5">
                   5
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee537f811077884-6">
                   6
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee537f811077884-7">
                   7
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee537f811077884-8">
                   8
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee537f811077884-9">
                   9
                  </div>
                  <div class="crayon-num crayon-striped-num" data-line="crayon-5768661ee537f811077884-10">
                   10
                  </div>
                  <div class="crayon-num" data-line="crayon-5768661ee537f811077884-11">
                   11
                  </div>
                 </div>
                </td>
                <td class="crayon-code">
                 <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                  <div class="crayon-line" id="crayon-5768661ee537f811077884-1">
                   <span class="crayon-p">
                    # Load a JSON file
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee537f811077884-2">
                   <span class="crayon-v">
                    people
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-o">
                    -
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-v">
                    read
                   </span>
                   <span class="crayon-sy">
                    .
                   </span>
                   <span class="crayon-e">
                    df
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    sqlContext
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-s">
                    "./examples/src/main/resources/people.json"
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-s">
                    "json"
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee537f811077884-3">
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee537f811077884-4">
                   <span class="crayon-p">
                    # Register this DataFrame as a table.
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee537f811077884-5">
                   <span class="crayon-e">
                    registerTempTable
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    people
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-s">
                    "people"
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee537f811077884-6">
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee537f811077884-7">
                   <span class="crayon-p">
                    # SQL statements can be run by using the sql method
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee537f811077884-8">
                   <span class="crayon-v">
                    teenagers
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-o">
                    &amp;
                   </span>
                   <span class="crayon-v">
                    lt
                   </span>
                   <span class="crayon-sy">
                    ;
                   </span>
                   <span class="crayon-o">
                    -
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-e">
                    sql
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    sqlContext
                   </span>
                   <span class="crayon-sy">
                    ,
                   </span>
                   <span class="crayon-h">
                   </span>
                   <span class="crayon-s">
                    "SELECT name FROM people WHERE age &amp;gt;= 13 AND age &amp;lt;= 19"
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee537f811077884-9">
                   <span class="crayon-e">
                    head
                   </span>
                   <span class="crayon-sy">
                    (
                   </span>
                   <span class="crayon-v">
                    teenagers
                   </span>
                   <span class="crayon-sy">
                    )
                   </span>
                  </div>
                  <div class="crayon-line crayon-striped-line" id="crayon-5768661ee537f811077884-10">
                   <span class="crayon-p">
                    ##    name
                   </span>
                  </div>
                  <div class="crayon-line" id="crayon-5768661ee537f811077884-11">
                   <span class="crayon-p">
                    ##1 Justin
                   </span>
                  </div>
                 </div>
                </td>
               </tr>
              </tbody>
             </table>
            </div>
           </div>
           <!-- [Format Time: 0.0149 seconds] -->
           <p>
           </p>
          </blockquote>
         </div>
        </div>
       </div>
       <div class="note">
        本文翻译自SparkR官方文档，这个是Spark 1.4中才有的，不过他还没发布，不过可以看这里
        <a href="http://people.apache.org/~pwendell/spark-releases/spark-1.4.0-rc4-docs/sparkr.html">
         http://people.apache.org/~pwendell/spark-releases/spark-1.4.0-rc4-docs/sparkr.html
        </a>
       </div>
      </div>
      <div>
       <strong>
        注：转载文章均来自于公开网络，仅供学习使用，不会用于任何商业用途，如果侵犯到原作者的权益，请您与我们联系删除或者授权事宜，联系邮箱：contact@dataunion.org。转载数盟网站文章请注明原文章作者，否则产生的任何版权纠纷与数盟无关。
       </strong>
      </div>
      <!--content_text-->
      <div class="fenxian">
       <!-- JiaThis Button BEGIN -->
       <div class="jiathis_style_32x32">
        <p class="jiathis_button_weixin">
        </p>
        <p class="jiathis_button_tsina">
        </p>
        <p class="jiathis_button_qzone">
        </p>
        <p class="jiathis_button_cqq">
        </p>
        <p class="jiathis_button_tumblr">
        </p>
        <a class="jiathis jiathis_txt jtico jtico_jiathis" href="http://www.jiathis.com/share" target="_blank">
        </a>
        <p class="jiathis_counter_style">
        </p>
       </div>
       <!-- JiaThis Button END -->
      </div>
     </article>
     <!--content-->
     <!--相关文章-->
     <div class="xianguan">
      <div class="xianguantitle">
       相关文章！
      </div>
      <ul class="pic">
       <li>
        <a href="http://dataunion.org/20824.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/09/t018630756a7e263b33-300x165.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/20824.html" rel="bookmark" title="如何判断一笔交易是否属于欺诈？你只是需要一点数据挖掘">
         如何判断一笔交易是否属于欺诈？你只是需要一点数据挖掘
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/20820.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/09/1-300x200.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/20820.html" rel="bookmark" title="人们对Python在企业级开发中的10大误解">
         人们对Python在企业级开发中的10大误解
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/20811.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/09/t0133fcacae8523307b_副本-300x200.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/20811.html" rel="bookmark" title="大神亲传：26条深度学习的金科玉律！">
         大神亲传：26条深度学习的金科玉律！
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/20808.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/09/640.webp-11-300x137.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/20808.html" rel="bookmark" title="我们是如何在一张地图上表现86万个数据的">
         我们是如何在一张地图上表现86万个数据的
        </a>
       </li>
      </ul>
     </div>
     <!--相关文章-->
     <div class="comment" id="comments">
      <!-- You can start editing here. -->
      <!-- If comments are open, but there are no comments. -->
      <div class="title">
       期待你一针见血的评论，Come on！
      </div>
      <div id="respond">
       <p>
        不用想啦，马上
        <a href="http://dataunion.org/wp-login.php?redirect_to=http%3A%2F%2Fdataunion.org%2F19410.html">
         "登录"
        </a>
        发表自已的想法.
       </p>
      </div>
     </div>
     <!-- .nav-single -->
    </div>
    <!--Container End-->
    <aside id="sitebar">
     <div class="sitebar_list2">
      <div class="wptag">
       <span class="tagtitle">
        热门标签+
       </span>
       <div class="tagg">
        <ul class="menu" id="menu-%e5%8f%8b%e6%83%85%e9%93%be%e6%8e%a5">
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-1605" id="menu-item-1605">
          <a href="http://taidizh.com/">
           泰迪智慧
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20884" id="menu-item-20884">
          <a href="http://www.transwarp.cn/">
           星环科技
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-3538" id="menu-item-3538">
          <a href="http://datall.org/">
           珈和遥感
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20888" id="menu-item-20888">
          <a href="http://www.chinahadoop.cn/">
           小象学院
          </a>
         </li>
        </ul>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <div class="textwidget">
       <div align="center">
        <a href="http://study.163.com/course/courseMain.htm?courseId=991022" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2016/03/dv.jpg"/>
        </a>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       文章分类
      </h4>
      <div class="tagcloud">
       <a class="tag-link-44" href="http://dataunion.org/category/industry/demo" style="font-size: 10.204724409449pt;" title="4个话题">
        Demo展示
       </a>
       <a class="tag-link-31" href="http://dataunion.org/category/experts" style="font-size: 15.826771653543pt;" title="52个话题">
        专家团队
       </a>
       <a class="tag-link-870" href="http://dataunion.org/category/tech/ai" style="font-size: 19.795275590551pt;" title="273个话题">
        人工智能
       </a>
       <a class="tag-link-488" href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f" style="font-size: 8pt;" title="1个话题">
        加入数盟
       </a>
       <a class="tag-link-869" href="http://dataunion.org/category/tech/viz" style="font-size: 17.204724409449pt;" title="93个话题">
        可视化
       </a>
       <a class="tag-link-30" href="http://dataunion.org/category/partners" style="font-size: 10.645669291339pt;" title="5个话题">
        合作伙伴
       </a>
       <a class="tag-link-889" href="http://dataunion.org/category/parterc" style="font-size: 11.582677165354pt;" title="8个话题">
        合作会议
       </a>
       <a class="tag-link-104" href="http://dataunion.org/category/books" style="font-size: 12.96062992126pt;" title="15个话题">
        图书
       </a>
       <a class="tag-link-220" href="http://dataunion.org/category/tech/base" style="font-size: 19.850393700787pt;" title="281个话题">
        基础架构
       </a>
       <a class="tag-link-219" href="http://dataunion.org/category/tech/analysis" style="font-size: 19.409448818898pt;" title="232个话题">
        数据分析
       </a>
       <a class="tag-link-887" href="http://dataunion.org/category/tech/dm" style="font-size: 13.291338582677pt;" title="17个话题">
        数据挖掘
       </a>
       <a class="tag-link-34" href="http://dataunion.org/category/tech" style="font-size: 20.732283464567pt;" title="404个话题">
        文章
       </a>
       <a class="tag-link-1" href="http://dataunion.org/category/uncategorized" style="font-size: 22pt;" title="693个话题">
        未分类
       </a>
       <a class="tag-link-4" href="http://dataunion.org/category/events" style="font-size: 14.503937007874pt;" title="29个话题">
        活动
       </a>
       <a class="tag-link-890" href="http://dataunion.org/category/tech/%e6%b7%b1%e5%ba%a6%e5%ad%a6%e4%b9%a0" style="font-size: 10.204724409449pt;" title="4个话题">
        深度学习
       </a>
       <a class="tag-link-221" href="http://dataunion.org/category/tech/devl" style="font-size: 18.968503937008pt;" title="193个话题">
        编程语言
       </a>
       <a class="tag-link-888" href="http://dataunion.org/category/career" style="font-size: 15.661417322835pt;" title="48个话题">
        职业规划
       </a>
       <a class="tag-link-5" href="http://dataunion.org/category/jobs" style="font-size: 14.11811023622pt;" title="25个话题">
        职位
       </a>
       <a class="tag-link-871" href="http://dataunion.org/category/industry" style="font-size: 15.716535433071pt;" title="49个话题">
        行业
       </a>
       <a class="tag-link-613" href="http://dataunion.org/category/industry/case" style="font-size: 16.984251968504pt;" title="84个话题">
        行业应用
       </a>
       <a class="tag-link-885" href="http://dataunion.org/category/industry/news" style="font-size: 17.425196850394pt;" title="102个话题">
        行业资讯
       </a>
       <a class="tag-link-10" href="http://dataunion.org/category/training" style="font-size: 14.228346456693pt;" title="26个话题">
        课程
       </a>
       <a class="tag-link-16" href="http://dataunion.org/category/sources" style="font-size: 15.661417322835pt;" title="48个话题">
        资源
       </a>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       功能
      </h4>
      <ul>
       <li>
        <a href="http://dataunion.org/wp-login.php?action=register">
         注册
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/wp-login.php">
         登录
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/feed">
         文章
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/comments/feed">
         评论
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="https://cn.wordpress.org/" title="基于WordPress，一个优美、先进的个人信息发布平台。">
         WordPress.org
        </a>
       </li>
      </ul>
     </div>
    </aside>
    <div class="clear">
    </div>
   </div>
   <!--main-->
   ﻿
   <footer id="dibu">
    <div class="about">
     <div class="right">
      <ul class="menu" id="menu-%e5%ba%95%e9%83%a8%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-18024" id="menu-item-18024">
        <a href="http://dataunion.org/category/partners">
         合作伙伴
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20881" id="menu-item-20881">
        <a href="http://dataunion.org/contribute">
         文章投稿
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20872" id="menu-item-20872">
        <a href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f">
         加入数盟
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22441" id="menu-item-22441">
        <a href="http://dataunion.org/f-links">
         友情链接
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20874" id="menu-item-20874">
        <a href="http://dataunion.org/aboutus">
         关于数盟
        </a>
       </li>
      </ul>
      <p class="banquan">
       数盟社区        ，
        做最棒的数据科学社区
      </p>
     </div>
     <div class="left">
      <ul class="bottomlist">
       <li>
        <a href="http://weibo.com/DataScientistUnion  " target="_blank" 　title="">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weibo.png"/>
        </a>
       </li>
       <li>
        <a class="cd-popup-trigger" href="http://dataunion.org/19410.html#0">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weixin.png"/>
        </a>
       </li>
      </ul>
      <div class="cd-popup">
       <div class="cd-popup-container">
        <h1>
         扫描二维码,加微信公众号
        </h1>
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/2014-12-06-1515289049.png"/>
        <a class="cd-popup-close" href="http://dataunion.org/19410.html">
        </a>
       </div>
       <!-- cd-popup-container -->
      </div>
      <!-- cd-popup -->
     </div>
    </div>
    <!--about-->
    <div class="bottom">
     <a href="http://dataunion.org/">
      数盟社区
     </a>
     <a href="http://www.miitbeian.gov.cn/" rel="external nofollow" target="_blank">
      京ICP备14026740号
     </a>
     联系我们：
     <a href="mailto:contact@dataunion.org" target="_blank">
      contact@dataunion.org
     </a>
     <div class="tongji">
     </div>
     <!--bottom-->
     <div class="scroll" id="scroll" style="display:none;">
      ︿
     </div>
    </div>
   </footer>
   <!--dibu-->
  </div>
 </body>
</html>